home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / UTILS.PAK / GETTABLE.WFM < prev    next >
Encoding:
Text File  |  1995-07-18  |  8.5 KB  |  333 lines

  1. *******************************************************************************
  2. * PROGRAM:     Gettable.wfm
  3. *
  4. * WRITTEN BY:  Borland Samples Group
  5. *
  6. * DATE:        3/95
  7. *
  8. * UPDATED:     6/95
  9. *
  10. * REVISION:    $Revision:   1.14  $
  11. *
  12. * VERSION:     Visual dBASE
  13. *
  14. * DESCRIPTION: This is a tool for selecting a table from a list of tables.
  15. *
  16. * PARAMETERS:  None
  17. *
  18. * CALLS:       Buttons.cc    (Custom Controls file)
  19. *
  20. * USAGE:       DO Gettable.wfm
  21. *
  22. ********************************************************************************
  23.  
  24. #include <Messdlg.h>
  25.  
  26.  
  27. ** END HEADER -- do not remove this line*
  28. * Generated on 04/13/95
  29. *
  30. parameter bModal
  31. local f
  32. f = new GETTABLEFORM()
  33. if (bModal)
  34.    f.mdi = .F. && ensure not MDI
  35.    f.ReadModal()
  36. else
  37.    f.Open()
  38. endif
  39. CLASS GETTABLEFORM OF FORM
  40.    set procedure to &_dbwinhome.custom\Buttons.cc additive
  41.    this.ColorNormal = "N/BTNFACE"
  42.    this.OnClose = CLASS::FORM_ONCLOSE
  43.    this.Top = 1
  44.    this.Left = 5
  45.    this.TopMost = .F.
  46.    this.Text = "Table Selection"
  47.    this.Height = 11.4111
  48.    this.Width = 51.333
  49.    this.PageNo = 1
  50.    this.OnOpen = CLASS::ONOPEN
  51.  
  52.    DEFINE RECTANGLE RADIORECT OF THIS;
  53.        PROPERTY;
  54.          ColorNormal "BTNTEXT/BTNFACE",;
  55.          Top 1.5,;
  56.          Left 28.333,;
  57.          Text "",;
  58.          Height 5.3232,;
  59.          Width 23,;
  60.          PageNo 1,;
  61.          Border .T.
  62.  
  63.    DEFINE RECTANGLE TABLESRECT OF THIS;
  64.        PROPERTY;
  65.          ColorNormal "B/BtnFace",;
  66.          Top 1.1992,;
  67.          Left 0.3311,;
  68.          Text "Select a Table:",;
  69.          Height 10.1533,;
  70.          Width 27.1689,;
  71.          PageNo 1,;
  72.          Border .T.,;
  73.          FontBold .F.
  74.  
  75.    DEFINE TEXT DIRECTORYTEXT OF THIS;
  76.        PROPERTY;
  77.          ColorNormal "W+/BTNFACE",;
  78.          Top 0.1973,;
  79.          Left 0.3311,;
  80.          Text "",;
  81.          Height 0.7432,;
  82.          Width 42.002,;
  83.          PageNo 1,;
  84.          Border .F.,;
  85.          FontBold .F.
  86.  
  87.    DEFINE LISTBOX TABLELIST OF THIS;
  88.        PROPERTY;
  89.          ColorHighLight "B+/W",;
  90.          ColorNormal "WindowText/Window",;
  91.          OnLeftDblClick CLASS::OKBUTTON1_ONCLICK,;
  92.          Sorted .T.,;
  93.          ID 100,;
  94.          Top 1.8994,;
  95.          Left 1.3311,;
  96.          Height 9.3,;
  97.          Width 25.335,;
  98.          PageNo 1,;
  99.          DataSource "TABLES",;
  100.          FontBold .F.,;
  101.          OnOpen {;this.curSel = 1}
  102.  
  103.    DEFINE PUSHBUTTON DIRECTORYBUTTON OF THIS;
  104.        PROPERTY;
  105.          ColorNormal "BtnText/BtnFace",;
  106.          Top 5,;
  107.          Left 36.3281,;
  108.          Group .T.,;
  109.          Text "&Directory",;
  110.          Height 1.5293,;
  111.          OnClick CLASS::DIRECTORYBUTTON_ONCLICK,;
  112.          UpBitmap "RESOURCE #137",;
  113.          Width 14.1719,;
  114.          PageNo 1,;
  115.          FontBold .F.
  116.  
  117.    DEFINE RADIOBUTTON DIRRADIO OF THIS;
  118.        PROPERTY;
  119.          Value .T.,;
  120.          ColorNormal "BTNTEXT/BTNFACE",;
  121.          Top 1.8994,;
  122.          Left 29,;
  123.          Group .T.,;
  124.          Text "Tables from D&irectory",;
  125.          Height 0.8057,;
  126.          Width 20,;
  127.          PageNo 1,;
  128.          FontBold .F.,;
  129.          OnChange CLASS::DIRRADIO_ONCHANGE
  130.  
  131.    DEFINE RADIOBUTTON DATABASERADIO OF THIS;
  132.        PROPERTY;
  133.          Value .F.,;
  134.          ColorNormal "BTNTEXT/BTNFACE",;
  135.          Top 2.7998,;
  136.          Left 29,;
  137.          Group .F.,;
  138.          Text "Tables from D&atabase",;
  139.          Height 0.8467,;
  140.          Width 20,;
  141.          PageNo 1,;
  142.          FontBold .F.,;
  143.          OnChange CLASS::DATABASERADIO_ONCHANGE
  144.  
  145.    DEFINE PUSHBUTTON DATABASEBUTTON OF THIS;
  146.        PROPERTY;
  147.          ColorNormal "BtnText/BtnFace",;
  148.          Top 5,;
  149.          Left 36.3281,;
  150.          Group .T.,;
  151.          Visible .F.,;
  152.          Text "&Login...",;
  153.          Height 1.5293,;
  154.          UpBitmap "RESOURCE #137",;
  155.          Width 14.1719,;
  156.          PageNo 1,;
  157.          FontBold .F.,;
  158.          OnClick CLASS::DATABASEBUTTON_ONCLICK
  159.  
  160.  
  161.    DEFINE ENTRYFIELD DATABASEENTRY OF THIS;
  162.        PROPERTY;
  163.          Value "",;
  164.          ColorHighLight "WINDOWTEXT/WINDOW",;
  165.          ColorNormal "N/W",;
  166.          Top 3.6996,;
  167.          Function "!S25",;
  168.          Left 29,;
  169.          Height 1.0293,;
  170.          Width 21.5,;
  171.          PageNo 1,;
  172.          Border .T.,;
  173.          FontBold .F.
  174.  
  175.    DEFINE OKBUTTON OKBUTTON1 OF THIS;
  176.        PROPERTY;
  177.          Top 8,;
  178.          Left 36.332,;
  179.          Group .T.,;
  180.          Height 1.5293,;
  181.          OnClick CLASS::OKBUTTON1_ONCLICK,;
  182.          Width 14.168,;
  183.          FontBold .F.
  184.  
  185.    DEFINE CANCELBUTTON CANCELBUTTON1 OF THIS;
  186.        PROPERTY;
  187.          Top 9.7998,;
  188.          Left 36.332,;
  189.          Group .T.,;
  190.          Height 1.5527,;
  191.          Width 14.168,;
  192.          FontBold .F.
  193.  
  194.  
  195.  
  196.    Procedure OnOpen
  197.    ****************************************************************************
  198.  
  199.    set procedure to &_dbwinhome.utils\Sql.wfm additive       && Procedure file
  200.  
  201.    form.saveDir = setto("directory")
  202.    if empty(setto("database"))
  203.       form.dirRadio.SetFocus()
  204.       form.directoryText.text = lower(form.saveDir)
  205.       form.tablesFromDatabase = .F.        && Indicates if tables are from database
  206.       form.serverName = .F.
  207.    else
  208.       form.databaseRadio.SetFocus()
  209.       form.databaseButton.OnClick()
  210.       form.serverName = setto("database")
  211.    endif
  212.  
  213.  
  214.    ****************************************************************************
  215.  
  216.    Procedure Form_OnClose
  217.    ****************************************************************************
  218.    private saveDir
  219.  
  220.    close procedure &_dbwinhome.custom\Buttons.cc, &_dbwinhome.utils\Sql.wfm
  221.  
  222.    if form.tablesFromDatabase
  223.       form.serverName = rtrim(form.databaseEntry.value)
  224.    endif
  225.    saveDir = form.saveDir
  226.    cd &saveDir
  227.  
  228.  
  229.    ****************************************************************************
  230.  
  231.    Procedure OkButton1_OnClick
  232.    ****************************************************************************
  233.    private curDir
  234.  
  235.    if form.tablesFromDatabase
  236.       form.selectedTable = form.tableList.Selected()
  237.    else
  238.       curDir = setto("directory") + "\"
  239.       form.selectedTable = upper(curDir + form.tableList.Selected())
  240.    endif
  241.  
  242.    form.Close()
  243.  
  244.    ****************************************************************************
  245.  
  246.    Procedure DirectoryButton_OnClick
  247.    ****************************************************************************
  248.  
  249.    private tablesDir
  250.  
  251.    tablesDir = getdirectory()
  252.    if .not. empty(tablesDir)
  253.       cd &tablesDir
  254.    endif
  255.  
  256.    *** Changes aren't registered unless lisbox is completely redefined
  257.    REDEFINE LISTBOX TABLELIST OF FORM;
  258.        PROPERTY;
  259.          ColorNormal "WindowText/Window",;
  260.          OnLeftDblClick CLASS::OKBUTTON1_ONCLICK,;
  261.          Height 9.3,;
  262.          Left 1.332,;
  263.          FontBold .F.,;
  264.          DataSource "TABLES",;
  265.          ColorHighLight "B+/W",;
  266.          ID 100,;
  267.          PageNo 1,;
  268.          Top 1.8232,;
  269.          OnOpen {;this.curSel = 1},;
  270.          Width 25.334
  271.    show object form.tableList
  272.    form.tableList.curSel = 1
  273.    form.tableList.SetFocus()
  274.  
  275.    form.directoryText.text = lower(tablesDir)
  276.  
  277.  
  278.    *******************************************************************************
  279.    Procedure DATABASEBUTTON_OnClick
  280.    *******************************************************************************
  281.    private databaseName
  282.  
  283.    databaseName = form.databaseEntry.value
  284.    on error HandleDatabaseError()
  285.    open database &databaseName
  286.    set database to &databaseName
  287.    databaseName = setto("database")
  288.    if .not. empty(databaseName)
  289.       form.directoryText.text = databaseName
  290.       show object form.tableList
  291.    else
  292.       form.databaseEntry.value = ""
  293.       form.dirRadio.SetFocus()
  294.    endif
  295.    on error
  296.  
  297.    ****************************************************************************
  298.  
  299.    Procedure DIRRADIO_OnChange
  300.    ****************************************************************************
  301.  
  302.    form.directoryButton.visible = this.Value
  303.    if this.Value
  304.       form.databaseEntry.value = ""
  305.       show object form.databaseEntry
  306.    endif
  307.    form.databaseEntry.enabled = .not. this.Value
  308.    form.tablesFromDatabase = .not. this.Value
  309.  
  310.  
  311.    ****************************************************************************
  312.  
  313.    Procedure DATABASERADIO_OnChange
  314.    ****************************************************************************
  315.  
  316.    form.databaseButton.visible = this.Value
  317.    form.databaseEntry.enabled = this.Value
  318.    if this.Value
  319.       form.databaseEntry.SetFocus()
  320.    endif
  321.    form.tablesFromDatabase = this.Value
  322.  
  323.  
  324.  
  325.  
  326. ENDCLASS
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.